package uz.edo.app.client.header;

import java.util.Locale;

import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.ResourceModel;

import uz.edo.app.admin.departmentPages.DepartmentListView;
import uz.edo.app.admin.organizationPages.OrganisationListView;
import uz.edo.app.admin.privilegePages.PrivilegeListView;
import uz.edo.app.admin.rolePages.RoleListView;
import uz.edo.app.admin.userPages.UserListView;
import uz.edo.app.client.Login;
import uz.edo.app.client.SignOut;
import uz.edo.app.client.core.MySession;
import uz.edo.app.client.ui.doc.DocListView;
import uz.edo.db.bean.User;
import uz.edo.utils.Constants;

public class MyHeader extends Panel implements Constants {

	private static final long serialVersionUID = -4228398359228711344L;
	public WebMarkupContainer headerMenu;
    private User user;
    private MySession session;

    @SuppressWarnings("unchecked")
	public MyHeader(String id) {
        super(id);

        session = (MySession)getSession();
        user = session.getUser();
        WebMarkupContainer topPanel = new WebMarkupContainer("topPanel");
        topPanel.add(new Label("userlang", new ResourceModel("user_lang")));
        topPanel.add(new Label("user", user.getLastName() + " " + user.getFirstName()));
        topPanel.setVisible(true);
        add(topPanel);
        headerMenu = new WebMarkupContainer("headerMenu");
        headerMenu.add(new BookmarkablePageLink("registrationdoc", DocListView.class));
        //.setVisible(user.isPrivileged(SU) || user.isPrivileged(SYSADMIN)));

//        headerMenu.add(new BookmarkablePageLink("department", DepartmentListView.class).setVisible(user.isPrivileged(SU) || user.isPrivileged(SYSADMIN)));
//        headerMenu.add(new BookmarkablePageLink("user", UserListView.class));
//        headerMenu.add(new BookmarkablePageLink("role", RoleListView.class));
//        headerMenu.add(new BookmarkablePageLink("privilege", PrivilegeListView.class).setVisible(user.isPrivileged(SU)));
        Link logout = new Link("signout") {
            @Override
            public void onClick() {
//                session.setUser(null);
                setResponsePage(SignOut.class);
            }
        };
        headerMenu.add(logout);
        add(headerMenu);
    }
}

